/*
 * @Author: yangzonglong
 * @Date: 2021-07-28 14:05:11
 * @version: v1.0.0
 * @Descripttion: 导入导出json
 * @LastEditors: yangzonglong
 * @LastEditTime: 2021-07-28 14:15:03
 * @Auditor: 
 */
function autoClick(obj: any) {
  const ev = document.createEvent('MouseEvents');
  ev.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
  obj.dispatchEvent(ev);
}

export function exportJson(filename: string, data: any) {
  const urlObject = window.URL || window.webkitURL || window;
  const export_blob = new Blob([data]);
  const createA: HTMLElement  = document.createElementNS('http://www.w3.org/1999/xhtml', 'a');
  (createA as any).href = urlObject.createObjectURL(export_blob);
  (createA as any).download = filename;
  autoClick(createA);
}
